package com.welsy.usermgt.business
{
	import com.welsy.usermgt.vo.SearchVO;
	import mx.controls.Alert;
	import com.welsy.usermgt.vo.UserVO;
	import com.adobe.cairngorm.business.ServiceLocator;
	import mx.rpc.soap.mxml.WebService;
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.logging.Log;
	
	public class EditUserDelegate 
	{
		private var responder : IResponder;
		private var service : Object;
		
		public function EditUserDelegate( responder : IResponder ) {
			//Recorded in Services.mxml
			this.responder = responder;
			this.service = ServiceLocator.getInstance().getWebService("UserMgtService") as WebService;
		}
		
		public function performEdit(userVO : UserVO):void {
			//Create the request
			var op : AbstractOperation = service.getOperation("SaveUser");
			op.arguments.SaveUserRequest.UserId = userVO.UserId;
			op.arguments.SaveUserRequest.FirstName = userVO.FirstName;
			op.arguments.SaveUserRequest.LastName = userVO.LastName;
			op.arguments.SaveUserRequest.Login = userVO.Login;
			op.arguments.SaveUserRequest.Email = userVO.Email;
			op.arguments.SaveUserRequest.SubSystemId = userVO.SubSystemId;
			op.arguments.SaveUserRequest.RoleId = userVO.RoleId;
			
			var token : AsyncToken = service.SaveUser();
			token.addResponder(responder);
		}		
	}
}